home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / copperfun.lha / cop_lines.s next >
Encoding:
Text File  |  1992-12-31  |  4.4 KB  |  149 lines

  1. ***********************************************************
  2. * This shows how to manipulate the colors in the copper to
  3. * produce a neat "scrolling" effect.
  4. * 1992 Epsilon
  5. ***********************************************************
  6.  
  7. WaitVblank    MACRO
  8. .\@1        move.l    4(a5),d0
  9.         andi.l    #$3ff00,d0
  10.         cmpi.l    #$0f300,d0
  11.         bne.b    .\@1
  12. .\@2        move.l    4(a5),d0
  13.         andi.l    #$3ff00,d0
  14.         cmpi.l    #$0f400,d0
  15.         bne.b    .\@2
  16.         ENDM
  17.  
  18. ***********************************************************
  19.  
  20.         bsr.w    TakeSystem
  21. MouseWait:    WaitVblank
  22.  
  23.         bsr.b    Line1Alter
  24.         bsr.b    Line2Alter
  25.  
  26.         btst.b    #6,$bfe001    ; wait for left mouse button
  27.         bne.s    MouseWait
  28.  
  29.         bsr.w    RestoreSystem
  30.         rts
  31.  
  32. ***********************************************************    
  33.  
  34. Line1Alter:    move.l    #60,d0        ; 60, 4 pixel location per raster
  35.         lea    line+6,a0    ; first position in copper
  36.  
  37. top:        cmpi.w    #$0fff,(a0)    ; is color white?
  38.         bne.s    .1
  39.         clr.w    (a0)+        ; set to black
  40.         bra.s    .2
  41. .1:        add.w    #$0111,(a0)+    ; next gray shade
  42. .2:        addq.l    #2,a0        ; next position
  43.         dbra    d0,top        ; loop
  44.         rts
  45.  
  46. ***********************************************************    
  47.  
  48. Line2Alter:    addq.l    #1,line_count
  49.         cmpi.l    #$20,line_count    
  50.         bne.s    move_line
  51.         neg.b    direction
  52.         move.l    #0,line_count
  53.     
  54. move_line:    move.b    direction,d3
  55.         add.b    d3,line2        ; move line
  56.         add.b    d3,endl2        ; move bottom of line or bonus
  57.                     ;   garbage will result
  58.         move.l    #60,d0            ; there are 60, 4 pixel locations per line
  59.         lea    line2+6,a0        ; address of color
  60.         move.l    table_ptr,a1        ; address of new color in table
  61. top2:        cmpi.w    #$ffff,(a1)        ; end of color table?
  62.         bne.s    looper            ; no!
  63.         lea    table,a1        ; set it to start of table
  64. looper:        move.w    (a1)+,(a0)+        ; move color and get next one
  65.         addq.l    #2,a0            ; next location in copper list
  66.         dbra    d0,top2            ; loop
  67.  
  68.         move.l    table_ptr,a1        ; it the start color the last
  69.         cmp.l    #$ffff,(a1)        ;   color in the list?
  70.         beq.s    it_trash        ; yes
  71.         addq.l    #2,table_ptr        ; get next color
  72.         bra.s    it_ok
  73. it_trash:    move.l    #table,table_ptr    ; set ptr. to start of list
  74. it_ok:        rts
  75.  
  76. ***********************************************************    
  77. * If any of this confuses you totally, read the following:
  78. *    Amiga System Programmer's Guide, pp. 91-92, 94-96
  79. *
  80. *    Amiga Hardware Referance Manual, pp. 213, 217, 274, 325-326
  81. ***********************************************************
  82.  
  83. TakeSystem:    move.l    #$dff000,a5        ; Custom chip base
  84.         move.l    #Copper,$80(a5)        ; install copper
  85.         rts                ; Done
  86.  
  87. ***********************************************************
  88.  
  89. RestoreSystem:    move.l    #$dff000,a5        ; Custom chip base
  90.  
  91.         movea.l    4.w,a6            ; ExecBase
  92.         lea    GraphicsName,a1        ; "graphics.library"
  93.         jsr    -$198(a6)        ; OldOpenLibrary()
  94.         move.l    d0,a1            ; Copy ptr to GfxBase
  95.         move.l    $26(a1),$80(a5)        ; Install old system copperlist
  96.         jsr    -$19e(a6)        ; CloseLibrary()
  97.         rts                ; Done
  98.  
  99. ***********************************************************    
  100.  
  101.         section fish,data
  102.  
  103. table:        dc.w    $0000,$0001,$0003,$0005,$0007,$0009,$000b,$000d,$000f
  104.         dc.w    $000f,$000d,$000b,$0009,$0007,$0005,$0003,$0001,$0000
  105.         dc.w    $0000,$0100,$0300,$0500,$0700,$0900,$0b00,$0d00,$0f00
  106.         dc.w    $0f00,$0d00,$0b00,$0900,$0700,$0500,$0300,$0100,$0000
  107.         dc.w    $0000,$0010,$0030,$0050,$0070,$0090,$00b0,$00d0,$00f0
  108.         dc.w    $00f0,$00d0,$00b0,$0090,$0070,$0050,$0030,$0010,$0000
  109.         dc.w    $0000,$0310,$0510,$0920,$0b30,$0e30,$0e50,$0f70,$0fb0
  110.         dc.w    $0fb0,$0f70,$0e50,$0e30,$0b30,$0920,$0510,$0310,$0000
  111.         dc.w    $ffff
  112.  
  113. table_ptr:    dc.l    table
  114. line_count:    dc.l    0
  115.  
  116. direction:    dc.b    1
  117. GraphicsName:    dc.b    'graphics.library',0
  118.         EVEN
  119.  
  120. ***********************************************************    
  121.  
  122.         section    squid,data_c
  123.         
  124.  
  125. Copper:        dc.l    $01000000,$01020000,$01040000,$01080000,$010a0000
  126.         dc.l    $008e2c81,$0090f4c1,$00920038,$009400d0
  127.  
  128. line:        dc.w    $900f,$fffe
  129.         dc.l    $01800000,$01800fff,$01800eee,$01800ddd,$01800ccc
  130.         dc.l    $01800bbb,$01800aaa,$01800999,$01800888,$01800777
  131.         dc.l    $01800666,$01800555,$01800444,$01800333,$01800222
  132.         dc.l    $01800111,$01800000,$01800111,$01800222,$01800333
  133.         dc.l    $01800444,$01800555,$01800666,$01800777,$01800888
  134.         dc.l    $01800999,$01800aaa,$01800bbb,$01800ccc,$01800ddd
  135.         dc.l    $01800eee,$01800fff,$01800eee,$01800ddd,$01800ccc
  136.         dc.l    $01800bbb,$01800aaa,$01800999,$01800888,$01800777
  137.         dc.l    $01800666,$01800555,$01800444,$01800333,$01800222
  138.         dc.l    $01800111,$01800000,$01800111,$01800222,$01800333
  139.         dc.l    $01800444,$01800555,$01800666,$01800777,$01800888
  140.         dc.l    $01800999,$01800aaa,$01800bbb,$01800ccc,$01800ddd
  141.         dc.l    $01800eee,$01800fff,$01800eee,$01800ddd,$910ffffe
  142.         dc.l    $01800000
  143. line2:        dc.l    $950ffffe
  144.         rept    64
  145.         dc.l    $01800000
  146.         endr
  147.  
  148. endl2:        dc.l    $960ffffe,$01800000,-2,-2
  149.